package microservices.spring_cloud_server;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import microservices.spring_cloud_server.filter.HTTPBearerAuthorizeAttribute;

@SpringBootApplication
// @EnableDiscoveryClient
public class ServerApplication {
	// spring boot的标准入口
	public static void main(String[] args) {
		new SpringApplicationBuilder(ServerApplication.class).web(true).run(args);
	}

	@Bean
	public FilterRegistrationBean HTTPBearerAuthorizeAttribute() {
		FilterRegistrationBean registrationBean = new FilterRegistrationBean();
		HTTPBearerAuthorizeAttribute httpBasicFilter = new HTTPBearerAuthorizeAttribute();
		registrationBean.setFilter(httpBasicFilter);
		List<String> urlPatterns = new ArrayList<String>();
		urlPatterns.add("/*");
		registrationBean.setUrlPatterns(urlPatterns);
		return registrationBean;
	}

}
